Hello, I'm currently trying to write a program which searches through all of the objects in a module. For each object, it needs to find links (within a certain link module), and increase a counter when it finds them. This part works fine, however each time it finds a link, it also needs to navigate to that object, and search for links in that object in order to count the number of links it has as well. This is what i've tried so far.
for o in mEnding do { the csrd_lnk_count variable works out fine, but it has problems trying to get the frd links. It gives me a syntax error. Does anyone know a better way of doing this? I think part of the problem may be that the source modules need to be open in order to read their links, could this be my problem? Thanks! fj91 - Wed Nov 18 14:09:27 EST 2015 |
Re: Searching for links inside links You are missing the variable declarations here. You need to be sure to use LinkRef s. A Link is only loaded, when the source and target module are opened. So you are missing the code to open the module. Additionally when looping over in-links you might want to get the "source" of the link, no the target.
Without any testing of the code, I would say It should be like:
LinkRef inlinkCSRD;
Link inlinkFRD;
Module mnCSRD;
Object oCSRD,o;
for o in mEnding do {
csrd_lnk_count = 0
frd_lnk_count = 0
for inlinkCSRD in (all (o <- sLinkModuleCSRD)) do {
ModuleVersion srcVersion = sourceVersion inlinkCSRD;
mnCSRD = data srcVersion
if (null mnCSRD) mnCSRD = load(srcVersion, false);
delete srcVersion
for oCSRD in mnCSRD do {
for inlinkFRD in (all (alloCSRD -> sLinkModuleFRD)) do {
frd_lnk_count++
}
}
csrd_lnk_count++
}
There are also posts on that forum that describe how to correctly iterate over links. See for example here:
Hope this helps, regards, Mathias |